<?php

class Bayar_Dao{

	
function __construct(){
		$koneksi = new Koneksi();
		$koneksi->_connect();
	}
	
	function add(Bayar $bayar){
		
		$sql = "
			INSERT 
			INTO
			cara_bayar
			(
				cara_bayar
			)
			VALUES
			(
				'".$bayar->cara_bayar."'
			)
		";
		mysql_query($sql);
	
	}
	
	function get($id_bayar){
	
		
		$sql = "
		SELECT
		*
		FROM
		cara_bayar
		WHERE
		id_bayar = '".$id_bayar."'
		";
		
		$bayar = false;
		
		$res = mysql_query($sql);
		
		if($res){
		
			$row = mysql_fetch_assoc($res);
		
			$bayar = new Bayar();
			$bayar->id_bayar = $row['id_bayar'];
			$bayar->cara_bayar = $row['cara_bayar'];
		}
		
		return $bayar;
	}
	function get_all(){
	
		$sql = "
		SELECT
		*
		FROM
		cara_bayar
		";
		
		$list_bayar = array();
		
		$res = mysql_query($sql);
		if($res){
			while($row = mysql_fetch_assoc($res)){
			
				$bayar = new Bayar();
				
				$bayar->id_bayar = $row['id_bayar'];
				$bayar->cara_bayar = $row['cara_bayar'];
				
				$list_bayar[] = $bayar;
			
			}
		}
				return $list_bayar;
	
	}
		function edit(Bayar $bayar){
		$sql ="
			UPDATE 
			cara_bayar
			SET
			cara_bayar='$bayar->cara_bayar'
			WHERE 
			id_bayar ='$bayar->id_bayar'
		";
		mysql_query($sql);
	
	}
	}
	class Bayar{

	var $id_bayar;
	var $cara_bayar;
	

}